<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Kategori_model extends CI_Model
{
	public function __construct()
	{
		parent::__construct();
	}
		
		
	public function insert_kategori($data)
	{			
		$this->db->insert('kategori', $data);
	}
		
	public function get_kategori($id)
	{
		$this->db->select('*');
		$this->db->where('id_kategori', $id);
		$query = $this->db->get('kategori');
		return $query->num_rows();
	}
	
		
	public function edit_kategori($id, $data)
	{
		$this->db->update('kategori', $data, "id_kategori = $id");
	}
	
	public function get_list_kategori()
	{
		$this->db->select('*');
		$query = $this->db->get('kategori');
		return $query->result();
	}
	
	public function get_list_daerah()
	{
		$this->db->select('*');
		$query = $this->db->get('daerah');
		return $query->result();
	}
	
	public function get_pass($id, $pass)
	{
		$this->db->select('password');
		$this->db->where('id_user', $id);
		$this->db->where('password', $pass);
		$query = $this->db->get('user');
		return $query->num_rows();
	}
	
	public function update_katakunci($id_user, $data)
	{
		$this->db->update('user', $data, "id_user = $id_user");
	}
	
	public function hapus_kategori($id)
	{
		$this->db->where('id_kategori', $id);
		$this->db->delete('kategori');
	}
	
	/////////////-----/////
	
	public function cari_akun($str)
	{
		$this->db->select('*');
		$this->db->like('username', $str);
		$this->db->like('nama_lengkap', $str);
		$query = $this->db->get('user');
		return $query->result();
	}
	
	public function cari_reviewer()
	{
		$this->db->select('*');
		$this->db->where('id_peran', '2');
		$query = $this->db->get('user');
		return $query->result();
	}
	
	public function cari_kontributor()
	{
		$this->db->select('*');
		$this->db->where('id_peran', '3');
		$query = $this->db->get('user');
		return $query->result();
	}
		

}